/**
 * Created by Mark_ren on 2016/11/28.
 * 苟富贵,無相忘
 */
var moment = require("moment");
var co = require('co');
var seqModule = require('../../../routes/createModules');
var seq = new seqModule();
var util = require('../../../common/util');


var qdWjController = {
    getQdWj: function (req, res) {
        co(function () {
            var params = {};
            var paramT = {};
            if (req.query.id != undefined) {
                params.id = parseInt(req.query.id);
            }
            if (req.query.wjType != undefined) {
                params.wjType = parseInt(req.query.wjType);
            }
            if (req.query.state != undefined) {
                params.state = parseInt(req.query.state);
            }
            var include = [{ model: seq.qdWjQuestionModule, include: [{ model: seq.qdWjCheckModule }] }];
            paramT.include = include;
            paramT.order = [[seq.qdWjQuestionModule, 'code'], [seq.qdWjQuestionModule, seq.qdWjCheckModule, 'code']];
            paramT.where = params;
            seq.qdWjModule.findAll(paramT).then(function (result) {
                res.json({ 'success': true, 'msg': '查询成功', 'result': result });
            })

        }).catch(function (e) {
            res.json({ 'success': false, 'msg': '查询失败' });
            console.log(e);
        })

    },
    getWjById: function (req, res) {
        co(function () {
            var paramT = {};
            paramT.where = req.params;
            seq.qdWjModule.findOne(paramT).then(function (result) {
                res.json({ 'success': true, 'msg': '查询成功', 'result': result });
            })

        }).catch(function (e) {
            res.json({ 'success': false, 'msg': '查询失败' });
            console.log(e);
        })
    }

}
module.exports = qdWjController;